package org.groupg.practice.guiPractice.tools;

import javax.swing.*;
import java.awt.*;

public class BasicFrameExample {
    public static void main(String[] args) {
        // 使用SwingUtilities确保线程安全
        SwingUtilities.invokeLater(() -> {
            // 创建主窗口
            JFrame frame = new JFrame("Java Swing 示例");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(800, 600);
            frame.setLocationRelativeTo(null); // 居中显示

            // 设置布局管理器
            frame.setLayout(new BorderLayout());

            // 添加组件
            frame.add(createMainPanel(), BorderLayout.CENTER);

            frame.setVisible(true);
        });
    }

    private static JPanel createMainPanel() {
        JPanel panel = new JPanel(new GridLayout(3, 2, 10, 10));
        panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

        return panel;
    }
}
